{layout name="layout" /}

<div class="Hui-article">
	<article class="cl pd-20">
		<p class="f-20 text-success">欢迎{$data_user.uname}</p>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-1">
				我的邮箱：</label>
			<div class="formControls col-xs-8 col-sm-2">
				<input type="text" class="input-text" id="email" name="email" value="{$data_user.email}" data-old="{$data_user.email}" disabled="true">
			</div>
			<div class="formControls col-xs-8 col-sm-2">
				<button class="btn btn-primary radius email" type="button" onClick="modify(this, 'email')" style="display:block;">修改</button>
				<button class="btn btn-success radius email" type="button" onClick="do_modify(this, 'email')" style="display:none;">确定</button>
				<button class="btn btn-deefault radius email" type="button" onClick="cancle(this, 'email')" style="display:none;">取消</button>
			</div>
		</div>
		<br />
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-1">
				我的笔名：</label>
			<div class="formControls col-xs-8 col-sm-2">
				<input type="text" class="input-text" id="pen_name" name="pen_name" value="{$data_user.pen_name}" data-old="{$data_user.pen_name}" disabled="true">
			</div>
			<div class="formControls col-xs-8 col-sm-2">
				<button class="btn btn-primary radius pen_name" type="button" style="display:block;" onClick="modify(this, 'pen_name')">修改</button>
				<button class="btn btn-success radius pen_name" type="button" style="display:none;" onClick="do_modify(this, 'pen_name')">确定</button>
				<button class="btn btn-deefault radius pen_name" type="button" style="display:none;" onClick="cancle(this, 'pen_name')">取消</button>
			</div>
		</div>
		<p style='margin:10px 0;'>
			[<a href="{:url('admin_user/modifypwd')}" style="color:blue;">修改密码</a> ]
		</p>
		<table class="table table-border table-bordered table-bg" style="min-width:900px;max-width:90%;">
			<thead>
				<tr>
					<th colspan="12" scope="col">信息统计</th>
				</tr>
				<tr class="text-c">
					<th width="10%" rowspan="2">统计</th>
					<th colspan="8" >文档库<span style="margin-left: 20px;">(总计: <span class="counts c-red"></span>)</span></th>
					<th width="10%" rowspan="2">产品库</th>
					<th width="10%" rowspan="2">图片库</th>
					<th width="10%"rowspan="2">管理员</th>
                </tr>
                <tr class="text-c">
                    <th>全案设计</th>
                    <th>软装设计</th>
                    <th>设计案例</th>
                    <th>工艺展示</th>
                    <th>设计团队</th>
                    <th>施工管理</th>
                    <th>主材联盟</th>
                    <th>鸿锦动态</th>
                </tr>
			</thead>
			<tbody>
				<tr class="text-c">
					<td>总数</td>
					<td class="count">{php}echo model('ensemble')->count('id');{/php}</td>
					<td class="count">{php}echo model('soft')->count('id');{/php}</td>
					<td class="count">{php}echo model('example')->count('id');{/php}</td>
					<td class="count">{php}echo model('technology')->count('id');{/php}</td>
					<td class="count">{php}echo model('designer')->count('id');{/php}</td>
					<td class="count">{php}echo model('build')->count('id');{/php}</td>
					<td class="count">{php}echo model('material')->count('id');{/php}</td>
					<td class="count">{php}echo model('news')->count('id');{/php}</td>
					<td>0</td>
					<td>{php}echo model('pictures')->count('id');{/php}</td>
					<td>{php}echo model('admin_user')->count('id');{/php}</td>
				</tr>
			</tbody>
		</table>
		<table class="table table-border table-bordered table-bg mt-20" style="min-width:360px;max-width:38%;float:left;">
			<thead>
				<tr>
					<th colspan="2" scope="col">服务器信息</th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td>网站域名</td>
					<td>{$Think.server.http_host}</td>
				</tr>
				<tr>
					<td width="40%">服务器计算机名</td>
					<td>
						<span id="lbServerName">{$Think.server.server_name}</span>
					</td>
				</tr>
				<tr>
					<td>服务器IP地址</td>
					<td>{$Think.server.server_addr}</td>
				</tr>
				<tr>
					<td>服务器运行环境</td>
					<td>{$Think.php_os}</td>
				</tr>
				<tr>
					<td>WEB服务版本</td>
					<td>{$Think.server.server_software}</td>
				</tr>
				<tr>
					<td class="bodyTd1">网站已用空间大小</td>
					<td id="Info6" class="bodyTd1">
						<img src="/static/admin/images/loading.gif" alt="正在载入" class="mid"> Loading...
						<!-- <script type="text/javascript">ajax_getFilesSize('Info6');</script> -->
					</td>
				</tr>
				<tr>
					<td>网站版权所属</td>
					<td>
						<span id="Info7" runat="server" enableviewstate="false"></span>
						<span style="font-size:22px;">©</span> 北京德安健康管理有限公司版权所有
					</td>
				</tr>
				<tr>
					<td class="bodyTd1">网站技术支持</td>
					<td class="bodyTd1">
						<a href="javascript:void(0)" target="_blank">德安健康网络推广部</a>
					</td>
				</tr>
			</tbody>
			<thead>
				<tr>
					<th colspan="2" scope="col">客户端信息</th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td>当前使用的操作系统</td>
					<td>{php}echo os_info();{/php}</td>
				</tr>
				<tr>
					<td>当前使用的浏览器</td>
					<td>{php}echo browser_info();{/php}</td>
				</tr>
			</tbody>
		</table>
		<table class="table table-border table-bordered table-bg mt-20" style="min-width:540px;max-width:50%;float:left;margin-left:2%;">
			<thead>
				<tr>
					<th colspan="4" scope="col">最近登陆记录</th>
				</tr>
				<tr>
					<th class='text-c' width="10%">序号</th>
					<th class='text-c' width="30%">登陆时间</th>
					<th class='text-c' width="20%">登陆IP</th>
					<th class='text-c' width="20%">浏览器</th>
				</tr>
			</thead>
			<tbody>
				{foreach $data_login as $key=>$val}
				<tr>
					<td class='text-c'>{$key + 1}</td>
					<td>{$val.login_time|date="Y-m-d H:i:s", ###}</td>
					<td>{$val.login_ip|inet_ntoa}</td>
					<td>{$val.browser}</td>
				</tr>
				{/foreach}
			</tbody>
		</table>
	</article>
</div>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
    function counts(){
        var num = 0;
        $(".count").each(function(x){
            num += parseInt($(this).text());
        });
        return num;
    }

    $(".counts").text(counts());

	function modify(obj, field) {
		$("#" + field).attr('disabled', false);
		$("#" + field).focus();
		$("." + field).css('display', 'inline');
		$(obj).css('display', 'none');
	}

	function do_modify(obj, field) {
		var value = $("#" + field).val();

        if (field == "email") {
            if (testEmail(value) == false) {
                layer.msg('邮箱格式不正确', {
                    icon: 5,
                    time: 1000
                });
                return false;
            }
        }

		$.post("modify", {
			'value': value,
			'field': field
		}, function (data) {
			if (data.code == 2) {
				layer.msg(data.msg, {
					icon: 1,
					time: 1000
				});
				$("#" + field).attr('disabled', true);
				$("." + field).css('display', 'none');
				$(obj).prevAll(".btn-primary").css('display', 'inline');
			} else {
				layer.msg(data.msg, {
					icon: 5,
					time: 1000
				});
				return false;
			}
		}, 'json');
	}

	function cancle(obj, field) {
		var old=$("#"+field).data('old');
		$("#" + field).attr('disabled', true);
		$("#" + field).val(old);
		$("." + field).css('display', 'none');
		$(obj).prevAll(".btn-primary").css('display', 'inline');
	}
</script>
<!--请在上方写此页面业务相关的脚本-->